package com.xj.toOffer.nowCoder;

/**
 * @author: xujiang
 * @createTime: 2021/7/21 13:50:58
 */
public class JZ2 {
    public static String replaceSpace (String s) {
        // write code here
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (' ' == c) {
                sb.append("%20");
            } else {
                sb.append(s.charAt(i));
            }
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String replaceSpace = replaceSpace("We Are Happy");
        System.out.println(replaceSpace);
        System.out.println("%20");
    }
}
